﻿using System.Runtime.InteropServices;

namespace System
{
	public partial class ProcessMemory
	{
		[Flags]
		public enum ProcessAccessType : uint
		{
			PROCESS_TERMINATE = (0x0001),
			PROCESS_CREATE_THREAD = (0x0002),
			PROCESS_SET_SESSIONID = (0x0004),
			PROCESS_VM_OPERATION = (0x0008),
			PROCESS_VM_READ = (0x0010),
			PROCESS_VM_WRITE = (0x0020),
			PROCESS_DUP_HANDLE = (0x0040),
			PROCESS_CREATE_PROCESS = (0x0080),
			PROCESS_SET_QUOTA = (0x0100),
			PROCESS_SET_INFORMATION = (0x0200),
			PROCESS_QUERY_INFORMATION = (0x0400)
		}
		[DllImport("kernel32.dll")]
		static extern int OpenProcess(uint dwDesiredAccess, int bInheritHandle, int dwProcessId);
		[DllImport("kernel32.dll")]
		static extern int CloseHandle(int hObject);
		[DllImport("kernel32.dll")]
		static extern int ReadProcessMemory(int hProcess, int lpBaseAddress, byte[] buffer, int size, out int lpNumberOfBytesRead);
		[DllImport("kernel32.dll")]
		static extern int WriteProcessMemory(int hProcess, int lpBaseAddress, byte[] buffer, int size, out int lpNumberOfBytesWritten);
	}
}